package com.example.tacocloud.dao;

import com.example.tacocloud.bean.Ingredient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class IngredientByIdConverter implements Converter<String, Ingredient> {
    private IngredientRepository ir;

    @Autowired
    public IngredientByIdConverter(IngredientRepository ir) {
        this.ir = ir;
    }

    @Override
    public Ingredient convert(String id) {
        return ir.findOne(id);
    }
}
